// pages/logs/healthData/healthData.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //血压初始化
    chartXueYaData: {},
    optsA: {
      color: ["#6F8FFF", "#FE6A3D"],
      padding: [15, 10, 0, 15],
      enableScroll: false,
      legend: {},
      xAxis: {
        disableGrid: true
      },
      yAxis: {
        gridType: "dash",
        dashLength: 2,
      },
      extra: {
        line: {
          type: "curve",
          width: 2,
          activeType: "hollow",
          showValue: false
        }
      }
    },
    //血糖初始化
    chartXueTangData: {},
    optsB: {
      color: ["#FE6A3D"],
      padding: [15, 10, 0, 15],
      enableScroll: false,
      legend: {},
      xAxis: {
        disableGrid: true
      },
      yAxis: {
        gridType: "dash",
        dashLength: 2,
      },
      extra: {
        line: {
          type: "curve",
          width: 2,
          activeType: "hollow",
          showValue: false
        }
      }
    },
    //心率初始化
    chartXinLvData: {},
    optsC: {
      color: ["#6F8FFF"],
      padding: [15, 10, 0, 15],
      enableScroll: false,
      legend: {},
      xAxis: {
        disableGrid: true
      },
      yAxis: {
        gridType: "dash",
        dashLength: 2,
      },
      extra: {
        line: {
          type: "curve",
          width: 2,
          activeType: "hollow",
          showValue: false
        }
      }
    }
  },

  //获取血压数据
  getXueYaServerData() {
    setTimeout(() => {
      let res = {
        categories: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"],
        series: [{
            name: "舒张压",
            data: [50, 60, 65, 67, 60, 55, 48, 42, 50, 60, 68]
          },
          {
            name: "收缩压",
            data: [80, 86, 90, 96, 92, 84, 80, 82, 88, 95, 100]
          }
        ]
      };
      this.setData({
        chartXueYaData: JSON.parse(JSON.stringify(res))
      });
    }, 100);
  },

  //获取血糖数据
  getXueTangServerData() {
    setTimeout(() => {
      let res = {
        categories: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"],
        series: [{
          name: "血糖",
          data: [3.2, 3.6, 4.0, 4.6, 6.0, 8.0, 8.3, 10.2, 8.4, 8.1, 6.4]
        }]
      };
      this.setData({
        chartXueTangData: JSON.parse(JSON.stringify(res))
      });
    }, 100);
  },

  //获取心率数据
  getXinLvServerData() {
    setTimeout(() => {
      let res = {
        categories: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"],
        series: [{
          name: "心率",
          data: [80, 86, 90, 96, 92, 84, 80, 82, 88, 95, 100]
        }]
      };
      this.setData({
        chartXinLvData: JSON.parse(JSON.stringify(res))
      });
    }, 100);
  },

  toFamily() {
    wx.navigateBack();
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    this.getXueYaServerData(); //血压
    this.getXueTangServerData(); //血糖
    this.getXinLvServerData(); //心率
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})